package cn.js.ccit.flowersmall.product.controller;

import cn.js.ccit.flowersmall.product.entity.ProductEntity;
import cn.js.ccit.flowersmall.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
//@CrossOrigin(originPatterns = "*", methods = {RequestMethod.GET, RequestMethod.POST})
public class ProductController {
    @Autowired
    ProductService service;
    @GetMapping("/products")
    public List<ProductEntity> products(){
        return service.findProducts();
    }

    @GetMapping("/product")
    public ProductEntity product(Long id){
        return service.getProductById(id);
    }

}
